package Java.BlackHorse.Function;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Collectors;

public class FunctionDemo7 {
    public static void main(String[] args) {
        /*
        * 需求：
        * 集合中存储一些字符串的数据，收集到Student类型的数组当中
        * */
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"张三丰,16","周芷若,20","赵敏,30","张强,35","张无忌,40");
        Student[] arr = list.
                stream().
                map(Student::new).//引用Student类的工作方法,创建新的Student对象
                toArray(Student[]::new);//引用数组的方法，创建Student数组
        System.out.println(Arrays.toString(arr));
    }
}
